import { Component, OnInit } from '@angular/core';
import { takeUntil, timer } from 'rxjs';

import { DestroyService, TipsModalService } from '@core/base';
import { AboutTabService } from '@share/base/about-tab/about-tab.service';
import { NzMessageService } from 'ng-zorro-antd/message';

@Component({
  selector: 'app-modal-tips',
  templateUrl: './modal-tips.component.html',
  styleUrls: ['./modal-tips.component.less'],
  providers: [AboutTabService, DestroyService]
})
export class ModalTipsComponent implements OnInit {
  userVisible = false;
  userid!: string;

  constructor(private destroySrc: DestroyService, private aboutTabSrc: AboutTabService, private infoModalSrc: TipsModalService, private messageSrc: NzMessageService) {}
  ngOnInit(): void {
    timer(0, 1000)
      .pipe(takeUntil(this.destroySrc))
      .subscribe(i => {
        console.log(i);
        this.userid = `${i}`;
      });
  }

  info(): void {
    this.infoModalSrc.info('<b>这是描述信息(粗体)</b>').subscribe(() => this.messageSrc.info('窗口关闭'));
  }

  success(): void {
    this.infoModalSrc.success('<b style="color: green;">这是成功信息(粗体,绿色)</b>').subscribe(() => this.messageSrc.success('窗口关闭'));
  }

  fail(): void {
    this.infoModalSrc.fail('这是失败信息').subscribe(() => this.messageSrc.success('窗口关闭'));
  }

  warning(): void {
    this.infoModalSrc.warning('这是警告信息').subscribe(() => this.messageSrc.success('窗口关闭'));
  }

  about(): void {
    this.aboutTabSrc.show().subscribe(data => {
      console.log(data);
      this.messageSrc.info('窗口关闭');
    });
  }

  showUser(): void {
    this.userVisible = true;
  }
}
